<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Doubly-Linked Lists: GLib Reference Manual</title>
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot">
<link rel="home" href="index.html" title="GLib Reference Manual">
<link rel="up" href="glib-data-types.html" title="GLib Data Types">
<link rel="prev" href="glib-data-types.html" title="GLib Data Types">
<link rel="next" href="glib-Singly-Linked-Lists.html" title="Singly-Linked Lists">
<meta name="generator" content="GTK-Doc V1.26.1 (XML mode)">
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="5"><tr valign="middle">
<td width="100%" align="left" class="shortcuts">
<a href="#" class="shortcut">Top</a><span id="nav_description">  <span class="dim">|</span> 
                  <a href="#glib-Doubly-Linked-Lists.description" class="shortcut">Description</a></span>
</td>
<td><a accesskey="h" href="index.html"><img src="home.png" width="16" height="16" border="0" alt="Home"></a></td>
<td><a accesskey="u" href="glib-data-types.html"><img src="up.png" width="16" height="16" border="0" alt="Up"></a></td>
<td><a accesskey="p" href="glib-data-types.html"><img src="left.png" width="16" height="16" border="0" alt="Prev"></a></td>
<td><a accesskey="n" href="glib-Singly-Linked-Lists.html"><img src="right.png" width="16" height="16" border="0" alt="Next"></a></td>
</tr></table>
<div class="refentry">
<a name="glib-Doubly-Linked-Lists"></a><div class="titlepage"></div>
<div class="refnamediv"><table width="100%"><tr>
<td valign="top">
<h2><span class="refentrytitle"><a name="glib-Doubly-Linked-Lists.top_of_page"></a>Doubly-Linked Lists</span></h2>
<p>Doubly-Linked Lists — linked lists that can be iterated over in both directions</p>
</td>
<td class="gallery_image" valign="top" align="right"></td>
</tr></table></div>
<div class="refsect1">
<a name="glib-Doubly-Linked-Lists.functions"></a><h2>Functions</h2>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="functions_return">
<col class="functions_name">
</colgroup>
<tbody>
<tr>
<td class="function_type">
<a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="returnvalue">GList</span></a> *
</td>
<td class="function_name">
<a class="link" href="glib-Doubly-Linked-Lists.html#g-list-append" title="g_list_append ()">g_list_append</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="returnvalue">GList</span></a> *
</td>
<td class="function_name">
<a class="link" href="glib-Doubly-Linked-Lists.html#g-list-prepend" title="g_list_prepend ()">g_list_prepend</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="returnvalue">GList</span></a> *
</td>
<td class="function_name">
<a class="link" href="glib-Doubly-Linked-Lists.html#g-list-insert" title="g_list_insert ()">g_list_insert</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="returnvalue">GList</span></a> *
</td>
<td class="function_name">
<a class="link" href="glib-Doubly-Linked-Lists.html#g-list-insert-before" title="g_list_insert_before ()">g_list_insert_before</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="returnvalue">GList</span></a> *
</td>
<td class="function_name">
<a class="link" href="glib-Doubly-Linked-Lists.html#g-list-insert-sorted" title="g_list_insert_sorted ()">g_list_insert_sorted</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="returnvalue">GList</span></a> *
</td>
<td class="function_name">
<a class="link" href="glib-Doubly-Linked-Lists.html#g-list-remove" title="g_list_remove ()">g_list_remove</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="returnvalue">GList</span></a> *
</td>
<td class="function_name">
<a class="link" href="glib-Doubly-Linked-Lists.html#g-list-remove-link" title="g_list_remove_link ()">g_list_remove_link</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="returnvalue">GList</span></a> *
</td>
<td class="function_name">
<a class="link" href="glib-Doubly-Linked-Lists.html#g-list-delete-link" title="g_list_delete_link ()">g_list_delete_link</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="returnvalue">GList</span></a> *
</td>
<td class="function_name">
<a class="link" href="glib-Doubly-Linked-Lists.html#g-list-remove-all" title="g_list_remove_all ()">g_list_remove_all</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<span class="returnvalue">void</span>
</td>
<td class="function_name">
<a class="link" href="glib-Doubly-Linked-Lists.html#g-list-free" title="g_list_free ()">g_list_free</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<span class="returnvalue">void</span>
</td>
<td class="function_name">
<a class="link" href="glib-Doubly-Linked-Lists.html#g-list-free-full" title="g_list_free_full ()">g_list_free_full</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="returnvalue">GList</span></a> *
</td>
<td class="function_name">
<a class="link" href="glib-Doubly-Linked-Lists.html#g-list-alloc" title="g_list_alloc ()">g_list_alloc</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<span class="returnvalue">void</span>
</td>
<td class="function_name">
<a class="link" href="glib-Doubly-Linked-Lists.html#g-list-free-1" title="g_list_free_1 ()">g_list_free_1</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="glib-Basic-Types.html#guint" title="guint ()"><span class="returnvalue">guint</span></a>
</td>
<td class="function_name">
<a class="link" href="glib-Doubly-Linked-Lists.html#g-list-length" title="g_list_length ()">g_list_length</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="returnvalue">GList</span></a> *
</td>
<td class="function_name">
<a class="link" href="glib-Doubly-Linked-Lists.html#g-list-copy" title="g_list_copy ()">g_list_copy</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="returnvalue">GList</span></a> *
</td>
<td class="function_name">
<a class="link" href="glib-Doubly-Linked-Lists.html#g-list-copy-deep" title="g_list_copy_deep ()">g_list_copy_deep</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="returnvalue">GList</span></a> *
</td>
<td class="function_name">
<a class="link" href="glib-Doubly-Linked-Lists.html#g-list-reverse" title="g_list_reverse ()">g_list_reverse</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="returnvalue">GList</span></a> *
</td>
<td class="function_name">
<a class="link" href="glib-Doubly-Linked-Lists.html#g-list-sort" title="g_list_sort ()">g_list_sort</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="glib-Basic-Types.html#gint" title="gint ()"><span class="returnvalue">gint</span></a>
</td>
<td class="function_name">
<span class="c_punctuation">(</span><a class="link" href="glib-Doubly-Linked-Lists.html#GCompareFunc" title="GCompareFunc ()">*GCompareFunc</a><span class="c_punctuation">)</span> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="returnvalue">GList</span></a> *
</td>
<td class="function_name">
<a class="link" href="glib-Doubly-Linked-Lists.html#g-list-insert-sorted-with-data" title="g_list_insert_sorted_with_data ()">g_list_insert_sorted_with_data</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="returnvalue">GList</span></a> *
</td>
<td class="function_name">
<a class="link" href="glib-Doubly-Linked-Lists.html#g-list-sort-with-data" title="g_list_sort_with_data ()">g_list_sort_with_data</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="glib-Basic-Types.html#gint" title="gint ()"><span class="returnvalue">gint</span></a>
</td>
<td class="function_name">
<span class="c_punctuation">(</span><a class="link" href="glib-Doubly-Linked-Lists.html#GCompareDataFunc" title="GCompareDataFunc ()">*GCompareDataFunc</a><span class="c_punctuation">)</span> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="returnvalue">GList</span></a> *
</td>
<td class="function_name">
<a class="link" href="glib-Doubly-Linked-Lists.html#g-list-concat" title="g_list_concat ()">g_list_concat</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<span class="returnvalue">void</span>
</td>
<td class="function_name">
<a class="link" href="glib-Doubly-Linked-Lists.html#g-list-foreach" title="g_list_foreach ()">g_list_foreach</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<span class="returnvalue">void</span>
</td>
<td class="function_name">
<span class="c_punctuation">(</span><a class="link" href="glib-Doubly-Linked-Lists.html#GFunc" title="GFunc ()">*GFunc</a><span class="c_punctuation">)</span> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="returnvalue">GList</span></a> *
</td>
<td class="function_name">
<a class="link" href="glib-Doubly-Linked-Lists.html#g-list-first" title="g_list_first ()">g_list_first</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="returnvalue">GList</span></a> *
</td>
<td class="function_name">
<a class="link" href="glib-Doubly-Linked-Lists.html#g-list-last" title="g_list_last ()">g_list_last</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="define_keyword">#define</td>
<td class="function_name">
<a class="link" href="glib-Doubly-Linked-Lists.html#g-list-previous" title="g_list_previous()">g_list_previous</a><span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="define_keyword">#define</td>
<td class="function_name">
<a class="link" href="glib-Doubly-Linked-Lists.html#g-list-next" title="g_list_next()">g_list_next</a><span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="returnvalue">GList</span></a> *
</td>
<td class="function_name">
<a class="link" href="glib-Doubly-Linked-Lists.html#g-list-nth" title="g_list_nth ()">g_list_nth</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="returnvalue">gpointer</span></a>
</td>
<td class="function_name">
<a class="link" href="glib-Doubly-Linked-Lists.html#g-list-nth-data" title="g_list_nth_data ()">g_list_nth_data</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="returnvalue">GList</span></a> *
</td>
<td class="function_name">
<a class="link" href="glib-Doubly-Linked-Lists.html#g-list-nth-prev" title="g_list_nth_prev ()">g_list_nth_prev</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="returnvalue">GList</span></a> *
</td>
<td class="function_name">
<a class="link" href="glib-Doubly-Linked-Lists.html#g-list-find" title="g_list_find ()">g_list_find</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="returnvalue">GList</span></a> *
</td>
<td class="function_name">
<a class="link" href="glib-Doubly-Linked-Lists.html#g-list-find-custom" title="g_list_find_custom ()">g_list_find_custom</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="glib-Basic-Types.html#gint" title="gint ()"><span class="returnvalue">gint</span></a>
</td>
<td class="function_name">
<a class="link" href="glib-Doubly-Linked-Lists.html#g-list-position" title="g_list_position ()">g_list_position</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="glib-Basic-Types.html#gint" title="gint ()"><span class="returnvalue">gint</span></a>
</td>
<td class="function_name">
<a class="link" href="glib-Doubly-Linked-Lists.html#g-list-index" title="g_list_index ()">g_list_index</a> <span class="c_punctuation">()</span>
</td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect1">
<a name="glib-Doubly-Linked-Lists.other"></a><h2>Types and Values</h2>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="name">
<col class="description">
</colgroup>
<tbody>
<tr>
<td class="datatype_keyword">struct</td>
<td class="function_name"><a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList">GList</a></td>
</tr>
<tr>
<td class="define_keyword">#define</td>
<td class="function_name"><a class="link" href="glib-Doubly-Linked-Lists.html#g-list-free1" title="g_list_free1">g_list_free1</a></td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect1">
<a name="glib-Doubly-Linked-Lists.includes"></a><h2>Includes</h2>
<pre class="synopsis">#include &lt;gmodule.h&gt;
</pre>
</div>
<div class="refsect1">
<a name="glib-Doubly-Linked-Lists.description"></a><h2>Description</h2>
<p>The <a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a> structure and its associated functions provide a standard
doubly-linked list data structure.</p>
<p>Each element in the list contains a piece of data, together with
pointers which link to the previous and next elements in the list.
Using these pointers it is possible to move through the list in both
directions (unlike the singly-linked <a class="link" href="glib-Singly-Linked-Lists.html" title="Singly-Linked Lists">GSList</a>,
which only allows movement through the list in the forward direction).</p>
<p>The double linked list does not keep track of the number of items 
and does not keep track of both the start and end of the list. If
you want fast access to both the start and the end of the list, 
and/or the number of items in the list, use a
<a class="link" href="glib-Double-ended-Queues.html" title="Double-ended Queues">GQueue</a> instead.</p>
<p>The data contained in each element can be either integer values, by
using one of the <a class="link" href="glib-Type-Conversion-Macros.html" title="Type Conversion Macros">Type Conversion Macros</a>,
or simply pointers to any type of data.</p>
<p>List elements are allocated from the <a class="link" href="glib-Memory-Slices.html" title="Memory Slices">slice allocator</a>,
which is more efficient than allocating elements individually.</p>
<p>Note that most of the <a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a> functions expect to be passed a pointer
to the first element in the list. The functions which insert
elements return the new start of the list, which may have changed.</p>
<p>There is no function to create a <a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a>. <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a> is considered to be
a valid, empty list so you simply set a <a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a>* to <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a> to initialize
it.</p>
<p>To add elements, use <a class="link" href="glib-Doubly-Linked-Lists.html#g-list-append" title="g_list_append ()"><code class="function">g_list_append()</code></a>, <a class="link" href="glib-Doubly-Linked-Lists.html#g-list-prepend" title="g_list_prepend ()"><code class="function">g_list_prepend()</code></a>,
<a class="link" href="glib-Doubly-Linked-Lists.html#g-list-insert" title="g_list_insert ()"><code class="function">g_list_insert()</code></a> and <a class="link" href="glib-Doubly-Linked-Lists.html#g-list-insert-sorted" title="g_list_insert_sorted ()"><code class="function">g_list_insert_sorted()</code></a>.</p>
<p>To visit all elements in the list, use a loop over the list:</p>
<div class="informalexample">
  <table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
    <tbody>
      <tr>
        <td class="listing_lines" align="right"><pre>1
2
3
4
5</pre></td>
        <td class="listing_code"><pre class="programlisting">GList <span class="gtkdoc opt">*</span>l<span class="gtkdoc opt">;</span>
<span class="keyword">for</span> <span class="gtkdoc opt">(</span>l <span class="gtkdoc opt">=</span> list<span class="gtkdoc opt">;</span> l <span class="gtkdoc opt">!=</span> NULL<span class="gtkdoc opt">;</span> l <span class="gtkdoc opt">=</span> l<span class="gtkdoc opt">-&gt;</span>next<span class="gtkdoc opt">)</span>
  <span class="gtkdoc opt">{</span>
    <span class="gtkdoc slc">// do something with l-&gt;data</span>
  <span class="gtkdoc opt">}</span></pre></td>
      </tr>
    </tbody>
  </table>
</div>

<p></p>
<p>To call a function for each element in the list, use <a class="link" href="glib-Doubly-Linked-Lists.html#g-list-foreach" title="g_list_foreach ()"><code class="function">g_list_foreach()</code></a>.</p>
<p>To loop over the list and modify it (e.g. remove a certain element)
a while loop is more appropriate, for example:</p>
<div class="informalexample">
  <table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
    <tbody>
      <tr>
        <td class="listing_lines" align="right"><pre>1
2
3
4
5
6
7
8
9
10
11</pre></td>
        <td class="listing_code"><pre class="programlisting">GList <span class="gtkdoc opt">*</span>l <span class="gtkdoc opt">=</span> list<span class="gtkdoc opt">;</span>
<span class="keyword">while</span> <span class="gtkdoc opt">(</span>l <span class="gtkdoc opt">!=</span> NULL<span class="gtkdoc opt">)</span>
  <span class="gtkdoc opt">{</span>
    GList <span class="gtkdoc opt">*</span>next <span class="gtkdoc opt">=</span> l<span class="gtkdoc opt">-&gt;</span>next<span class="gtkdoc opt">;</span>
    <span class="keyword">if</span> <span class="gtkdoc opt">(</span><span class="function">should_be_removed</span> <span class="gtkdoc opt">(</span>l<span class="gtkdoc opt">))</span>
      <span class="gtkdoc opt">{</span>
        <span class="gtkdoc slc">// possibly free l-&gt;data</span>
        list <span class="gtkdoc opt">=</span> <span class="function"><a href="glib-Doubly-Linked-Lists.html#g-list-delete-link">g_list_delete_link</a></span> <span class="gtkdoc opt">(</span>list<span class="gtkdoc opt">,</span> l<span class="gtkdoc opt">);</span>
      <span class="gtkdoc opt">}</span>
    l <span class="gtkdoc opt">=</span> next<span class="gtkdoc opt">;</span>
  <span class="gtkdoc opt">}</span></pre></td>
      </tr>
    </tbody>
  </table>
</div>

<p></p>
<p>To remove elements, use <a class="link" href="glib-Doubly-Linked-Lists.html#g-list-remove" title="g_list_remove ()"><code class="function">g_list_remove()</code></a>.</p>
<p>To navigate in a list, use <a class="link" href="glib-Doubly-Linked-Lists.html#g-list-first" title="g_list_first ()"><code class="function">g_list_first()</code></a>, <a class="link" href="glib-Doubly-Linked-Lists.html#g-list-last" title="g_list_last ()"><code class="function">g_list_last()</code></a>,
<a class="link" href="glib-Doubly-Linked-Lists.html#g-list-next" title="g_list_next()"><code class="function">g_list_next()</code></a>, <a class="link" href="glib-Doubly-Linked-Lists.html#g-list-previous" title="g_list_previous()"><code class="function">g_list_previous()</code></a>.</p>
<p>To find elements in the list use <a class="link" href="glib-Doubly-Linked-Lists.html#g-list-nth" title="g_list_nth ()"><code class="function">g_list_nth()</code></a>, <a class="link" href="glib-Doubly-Linked-Lists.html#g-list-nth-data" title="g_list_nth_data ()"><code class="function">g_list_nth_data()</code></a>,
<a class="link" href="glib-Doubly-Linked-Lists.html#g-list-find" title="g_list_find ()"><code class="function">g_list_find()</code></a> and <a class="link" href="glib-Doubly-Linked-Lists.html#g-list-find-custom" title="g_list_find_custom ()"><code class="function">g_list_find_custom()</code></a>.</p>
<p>To find the index of an element use <a class="link" href="glib-Doubly-Linked-Lists.html#g-list-position" title="g_list_position ()"><code class="function">g_list_position()</code></a> and
<a class="link" href="glib-Doubly-Linked-Lists.html#g-list-index" title="g_list_index ()"><code class="function">g_list_index()</code></a>.</p>
<p>To free the entire list, use <a class="link" href="glib-Doubly-Linked-Lists.html#g-list-free" title="g_list_free ()"><code class="function">g_list_free()</code></a> or <a class="link" href="glib-Doubly-Linked-Lists.html#g-list-free-full" title="g_list_free_full ()"><code class="function">g_list_free_full()</code></a>.</p>
</div>
<div class="refsect1">
<a name="glib-Doubly-Linked-Lists.functions_details"></a><h2>Functions</h2>
<div class="refsect2">
<a name="g-list-append"></a><h3>g_list_append ()</h3>
<pre class="programlisting"><a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="returnvalue">GList</span></a> *
g_list_append (<em class="parameter"><code><a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a> *list</code></em>,
               <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> data</code></em>);</pre>
<p>Adds a new element on to the end of the list.</p>
<p>Note that the return value is the new start of the list,
if <em class="parameter"><code>list</code></em>
 was empty; make sure you store the new value.</p>
<p>g_list_append() has to traverse the entire list to find the end,
which is inefficient when adding multiple elements. A common idiom
to avoid the inefficiency is to use <a class="link" href="glib-Doubly-Linked-Lists.html#g-list-prepend" title="g_list_prepend ()"><code class="function">g_list_prepend()</code></a> and reverse
the list with <a class="link" href="glib-Doubly-Linked-Lists.html#g-list-reverse" title="g_list_reverse ()"><code class="function">g_list_reverse()</code></a> when all elements have been added.</p>
<div class="informalexample">
  <table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
    <tbody>
      <tr>
        <td class="listing_lines" align="right"><pre>1
2
3
4
5
6
7
8
9
10</pre></td>
        <td class="listing_code"><pre class="programlisting"><span class="gtkdoc slc">// Notice that these are initialized to the empty list.</span>
GList <span class="gtkdoc opt">*</span>string_list <span class="gtkdoc opt">=</span> NULL<span class="gtkdoc opt">, *</span>number_list <span class="gtkdoc opt">=</span> NULL<span class="gtkdoc opt">;</span>

<span class="gtkdoc slc">// This is a list of strings.</span>
string_list <span class="gtkdoc opt">=</span> <span class="function"><a href="glib-Doubly-Linked-Lists.html#g-list-append">g_list_append</a></span> <span class="gtkdoc opt">(</span>string_list<span class="gtkdoc opt">,</span> <span class="string">&quot;first&quot;</span><span class="gtkdoc opt">);</span>
string_list <span class="gtkdoc opt">=</span> <span class="function"><a href="glib-Doubly-Linked-Lists.html#g-list-append">g_list_append</a></span> <span class="gtkdoc opt">(</span>string_list<span class="gtkdoc opt">,</span> <span class="string">&quot;second&quot;</span><span class="gtkdoc opt">);</span>

<span class="gtkdoc slc">// This is a list of integers.</span>
number_list <span class="gtkdoc opt">=</span> <span class="function"><a href="glib-Doubly-Linked-Lists.html#g-list-append">g_list_append</a></span> <span class="gtkdoc opt">(</span>number_list<span class="gtkdoc opt">,</span> <span class="function"><a href="glib-Type-Conversion-Macros.html#GINT-TO-POINTER:CAPS">GINT_TO_POINTER</a></span> <span class="gtkdoc opt">(</span><span class="number">27</span><span class="gtkdoc opt">));</span>
number_list <span class="gtkdoc opt">=</span> <span class="function"><a href="glib-Doubly-Linked-Lists.html#g-list-append">g_list_append</a></span> <span class="gtkdoc opt">(</span>number_list<span class="gtkdoc opt">,</span> <span class="function"><a href="glib-Type-Conversion-Macros.html#GINT-TO-POINTER:CAPS">GINT_TO_POINTER</a></span> <span class="gtkdoc opt">(</span><span class="number">14</span><span class="gtkdoc opt">));</span></pre></td>
      </tr>
    </tbody>
  </table>
</div>

<p></p>
<div class="refsect3">
<a name="g-list-append.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>list</p></td>
<td class="parameter_description"><p>a pointer to a <a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a></p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>data</p></td>
<td class="parameter_description"><p>the data for the new element</p></td>
<td class="parameter_annotations"> </td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect3">
<a name="g-list-append.returns"></a><h4>Returns</h4>
<p> either <em class="parameter"><code>list</code></em>
or the new start of the <a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a> if <em class="parameter"><code>list</code></em>
was <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a></p>
</div>
</div>
<hr>
<div class="refsect2">
<a name="g-list-prepend"></a><h3>g_list_prepend ()</h3>
<pre class="programlisting"><a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="returnvalue">GList</span></a> *
g_list_prepend (<em class="parameter"><code><a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a> *list</code></em>,
                <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> data</code></em>);</pre>
<p>Prepends a new element on to the start of the list.</p>
<p>Note that the return value is the new start of the list,
which will have changed, so make sure you store the new value. </p>
<div class="informalexample">
  <table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
    <tbody>
      <tr>
        <td class="listing_lines" align="right"><pre>1
2
3
4
5</pre></td>
        <td class="listing_code"><pre class="programlisting"><span class="gtkdoc slc">// Notice that it is initialized to the empty list.</span>
GList <span class="gtkdoc opt">*</span>list <span class="gtkdoc opt">=</span> NULL<span class="gtkdoc opt">;</span>

list <span class="gtkdoc opt">=</span> <span class="function"><a href="glib-Doubly-Linked-Lists.html#g-list-prepend">g_list_prepend</a></span> <span class="gtkdoc opt">(</span>list<span class="gtkdoc opt">,</span> <span class="string">&quot;last&quot;</span><span class="gtkdoc opt">);</span>
list <span class="gtkdoc opt">=</span> <span class="function"><a href="glib-Doubly-Linked-Lists.html#g-list-prepend">g_list_prepend</a></span> <span class="gtkdoc opt">(</span>list<span class="gtkdoc opt">,</span> <span class="string">&quot;first&quot;</span><span class="gtkdoc opt">);</span></pre></td>
      </tr>
    </tbody>
  </table>
</div>

<p></p>
<p>Do not use this function to prepend a new element to a different
element than the start of the list. Use <a class="link" href="glib-Doubly-Linked-Lists.html#g-list-insert-before" title="g_list_insert_before ()"><code class="function">g_list_insert_before()</code></a> instead.</p>
<div class="refsect3">
<a name="g-list-prepend.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>list</p></td>
<td class="parameter_description"><p>a pointer to a <a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a>, this must point to the top of the list</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>data</p></td>
<td class="parameter_description"><p>the data for the new element</p></td>
<td class="parameter_annotations"> </td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect3">
<a name="g-list-prepend.returns"></a><h4>Returns</h4>
<p> a pointer to the newly prepended element, which is the new
start of the <a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a></p>
</div>
</div>
<hr>
<div class="refsect2">
<a name="g-list-insert"></a><h3>g_list_insert ()</h3>
<pre class="programlisting"><a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="returnvalue">GList</span></a> *
g_list_insert (<em class="parameter"><code><a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a> *list</code></em>,
               <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> data</code></em>,
               <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gint" title="gint ()"><span class="type">gint</span></a> position</code></em>);</pre>
<p>Inserts a new element into the list at the given position.</p>
<div class="refsect3">
<a name="g-list-insert.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>list</p></td>
<td class="parameter_description"><p>a pointer to a <a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a>, this must point to the top of the list</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>data</p></td>
<td class="parameter_description"><p>the data for the new element</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>position</p></td>
<td class="parameter_description"><p>the position to insert the element. If this is
negative, or is larger than the number of elements in the
list, the new element is added on to the end of the list.</p></td>
<td class="parameter_annotations"> </td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect3">
<a name="g-list-insert.returns"></a><h4>Returns</h4>
<p> the (possibly changed) start of the <a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a></p>
</div>
</div>
<hr>
<div class="refsect2">
<a name="g-list-insert-before"></a><h3>g_list_insert_before ()</h3>
<pre class="programlisting"><a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="returnvalue">GList</span></a> *
g_list_insert_before (<em class="parameter"><code><a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a> *list</code></em>,
                      <em class="parameter"><code><a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a> *sibling</code></em>,
                      <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> data</code></em>);</pre>
<p>Inserts a new element into the list before the given position.</p>
<div class="refsect3">
<a name="g-list-insert-before.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>list</p></td>
<td class="parameter_description"><p>a pointer to a <a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a>, this must point to the top of the list</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>sibling</p></td>
<td class="parameter_description"><p>the list element before which the new element
is inserted or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a> to insert at the end of the list</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>data</p></td>
<td class="parameter_description"><p>the data for the new element</p></td>
<td class="parameter_annotations"> </td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect3">
<a name="g-list-insert-before.returns"></a><h4>Returns</h4>
<p> the (possibly changed) start of the <a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a></p>
</div>
</div>
<hr>
<div class="refsect2">
<a name="g-list-insert-sorted"></a><h3>g_list_insert_sorted ()</h3>
<pre class="programlisting"><a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="returnvalue">GList</span></a> *
g_list_insert_sorted (<em class="parameter"><code><a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a> *list</code></em>,
                      <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> data</code></em>,
                      <em class="parameter"><code><a class="link" href="glib-Doubly-Linked-Lists.html#GCompareFunc" title="GCompareFunc ()"><span class="type">GCompareFunc</span></a> func</code></em>);</pre>
<p>Inserts a new element into the list, using the given comparison 
function to determine its position.</p>
<p>If you are adding many new elements to a list, and the number of
new elements is much larger than the length of the list, use
<a class="link" href="glib-Doubly-Linked-Lists.html#g-list-prepend" title="g_list_prepend ()"><code class="function">g_list_prepend()</code></a> to add the new items and sort the list afterwards
with <a class="link" href="glib-Doubly-Linked-Lists.html#g-list-sort" title="g_list_sort ()"><code class="function">g_list_sort()</code></a>.</p>
<div class="refsect3">
<a name="g-list-insert-sorted.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>list</p></td>
<td class="parameter_description"><p>a pointer to a <a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a>, this must point to the top of the
already sorted list</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>data</p></td>
<td class="parameter_description"><p>the data for the new element</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>func</p></td>
<td class="parameter_description"><p>the function to compare elements in the list. It should
return a number &gt; 0 if the first parameter comes after the
second parameter in the sort order.</p></td>
<td class="parameter_annotations"> </td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect3">
<a name="g-list-insert-sorted.returns"></a><h4>Returns</h4>
<p> the (possibly changed) start of the <a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a></p>
</div>
</div>
<hr>
<div class="refsect2">
<a name="g-list-remove"></a><h3>g_list_remove ()</h3>
<pre class="programlisting"><a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="returnvalue">GList</span></a> *
g_list_remove (<em class="parameter"><code><a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a> *list</code></em>,
               <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gconstpointer" title="gconstpointer"><span class="type">gconstpointer</span></a> data</code></em>);</pre>
<p>Removes an element from a <a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a>.
If two elements contain the same data, only the first is removed.
If none of the elements contain the data, the <a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a> is unchanged.</p>
<div class="refsect3">
<a name="g-list-remove.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>list</p></td>
<td class="parameter_description"><p>a <a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a>, this must point to the top of the list</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>data</p></td>
<td class="parameter_description"><p>the data of the element to remove</p></td>
<td class="parameter_annotations"> </td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect3">
<a name="g-list-remove.returns"></a><h4>Returns</h4>
<p> the (possibly changed) start of the <a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a></p>
</div>
</div>
<hr>
<div class="refsect2">
<a name="g-list-remove-link"></a><h3>g_list_remove_link ()</h3>
<pre class="programlisting"><a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="returnvalue">GList</span></a> *
g_list_remove_link (<em class="parameter"><code><a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a> *list</code></em>,
                    <em class="parameter"><code><a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a> *llink</code></em>);</pre>
<p>Removes an element from a <a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a>, without freeing the element.
The removed element's prev and next links are set to <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>, so 
that it becomes a self-contained list with one element.</p>
<p>This function is for example used to move an element in the list
(see the example for <a class="link" href="glib-Doubly-Linked-Lists.html#g-list-concat" title="g_list_concat ()"><code class="function">g_list_concat()</code></a>) or to remove an element in
the list before freeing its data:</p>
<div class="informalexample">
  <table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
    <tbody>
      <tr>
        <td class="listing_lines" align="right"><pre>1
2
3</pre></td>
        <td class="listing_code"><pre class="programlisting">list <span class="gtkdoc opt">=</span> <span class="function"><a href="glib-Doubly-Linked-Lists.html#g-list-remove-link">g_list_remove_link</a></span> <span class="gtkdoc opt">(</span>list<span class="gtkdoc opt">,</span> llink<span class="gtkdoc opt">);</span>
<span class="function">free_some_data_that_may_access_the_list_again</span> <span class="gtkdoc opt">(</span>llink<span class="gtkdoc opt">-&gt;</span>data<span class="gtkdoc opt">);</span>
<span class="function"><a href="glib-Doubly-Linked-Lists.html#g-list-free">g_list_free</a></span> <span class="gtkdoc opt">(</span>llink<span class="gtkdoc opt">);</span></pre></td>
      </tr>
    </tbody>
  </table>
</div>

<p></p>
<div class="refsect3">
<a name="g-list-remove-link.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>list</p></td>
<td class="parameter_description"><p>a <a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a>, this must point to the top of the list</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>llink</p></td>
<td class="parameter_description"><p>an element in the <a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a></p></td>
<td class="parameter_annotations"> </td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect3">
<a name="g-list-remove-link.returns"></a><h4>Returns</h4>
<p> the (possibly changed) start of the <a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a></p>
</div>
</div>
<hr>
<div class="refsect2">
<a name="g-list-delete-link"></a><h3>g_list_delete_link ()</h3>
<pre class="programlisting"><a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="returnvalue">GList</span></a> *
g_list_delete_link (<em class="parameter"><code><a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a> *list</code></em>,
                    <em class="parameter"><code><a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a> *link_</code></em>);</pre>
<p>Removes the node link_ from the list and frees it. 
Compare this to <a class="link" href="glib-Doubly-Linked-Lists.html#g-list-remove-link" title="g_list_remove_link ()"><code class="function">g_list_remove_link()</code></a> which removes the node 
without freeing it.</p>
<div class="refsect3">
<a name="g-list-delete-link.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>list</p></td>
<td class="parameter_description"><p>a <a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a>, this must point to the top of the list</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>link_</p></td>
<td class="parameter_description"><p>node to delete from <em class="parameter"><code>list</code></em>
</p></td>
<td class="parameter_annotations"> </td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect3">
<a name="g-list-delete-link.returns"></a><h4>Returns</h4>
<p> the (possibly changed) start of the <a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a></p>
</div>
</div>
<hr>
<div class="refsect2">
<a name="g-list-remove-all"></a><h3>g_list_remove_all ()</h3>
<pre class="programlisting"><a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="returnvalue">GList</span></a> *
g_list_remove_all (<em class="parameter"><code><a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a> *list</code></em>,
                   <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gconstpointer" title="gconstpointer"><span class="type">gconstpointer</span></a> data</code></em>);</pre>
<p>Removes all list nodes with data equal to <em class="parameter"><code>data</code></em>
.
Returns the new head of the list. Contrast with
<a class="link" href="glib-Doubly-Linked-Lists.html#g-list-remove" title="g_list_remove ()"><code class="function">g_list_remove()</code></a> which removes only the first node
matching the given data.</p>
<div class="refsect3">
<a name="g-list-remove-all.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>list</p></td>
<td class="parameter_description"><p>a <a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a>, this must point to the top of the list</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>data</p></td>
<td class="parameter_description"><p>data to remove</p></td>
<td class="parameter_annotations"> </td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect3">
<a name="g-list-remove-all.returns"></a><h4>Returns</h4>
<p> the (possibly changed) start of the <a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a></p>
</div>
</div>
<hr>
<div class="refsect2">
<a name="g-list-free"></a><h3>g_list_free ()</h3>
<pre class="programlisting"><span class="returnvalue">void</span>
g_list_free (<em class="parameter"><code><a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a> *list</code></em>);</pre>
<p>Frees all of the memory used by a <a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a>.
The freed elements are returned to the slice allocator.</p>
<p>If list elements contain dynamically-allocated memory, you should
either use <a class="link" href="glib-Doubly-Linked-Lists.html#g-list-free-full" title="g_list_free_full ()"><code class="function">g_list_free_full()</code></a> or free them manually first.</p>
<div class="refsect3">
<a name="g-list-free.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody><tr>
<td class="parameter_name"><p>list</p></td>
<td class="parameter_description"><p>a <a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a></p></td>
<td class="parameter_annotations"> </td>
</tr></tbody>
</table></div>
</div>
</div>
<hr>
<div class="refsect2">
<a name="g-list-free-full"></a><h3>g_list_free_full ()</h3>
<pre class="programlisting"><span class="returnvalue">void</span>
g_list_free_full (<em class="parameter"><code><a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a> *list</code></em>,
                  <em class="parameter"><code><a class="link" href="glib-Datasets.html#GDestroyNotify" title="GDestroyNotify ()"><span class="type">GDestroyNotify</span></a> free_func</code></em>);</pre>
<p>Convenience method, which frees all the memory used by a <a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a>,
and calls <em class="parameter"><code>free_func</code></em>
 on every element's data.</p>
<div class="refsect3">
<a name="g-list-free-full.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>list</p></td>
<td class="parameter_description"><p>a pointer to a <a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a></p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>free_func</p></td>
<td class="parameter_description"><p>the function to be called to free each element's data</p></td>
<td class="parameter_annotations"> </td>
</tr>
</tbody>
</table></div>
</div>
<p class="since">Since: <a class="link" href="api-index-2-28.html#api-index-2.28">2.28</a></p>
</div>
<hr>
<div class="refsect2">
<a name="g-list-alloc"></a><h3>g_list_alloc ()</h3>
<pre class="programlisting"><a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="returnvalue">GList</span></a> *
g_list_alloc (<em class="parameter"><code><span class="type">void</span></code></em>);</pre>
<p>Allocates space for one <a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a> element. It is called by
<a class="link" href="glib-Doubly-Linked-Lists.html#g-list-append" title="g_list_append ()"><code class="function">g_list_append()</code></a>, <a class="link" href="glib-Doubly-Linked-Lists.html#g-list-prepend" title="g_list_prepend ()"><code class="function">g_list_prepend()</code></a>, <a class="link" href="glib-Doubly-Linked-Lists.html#g-list-insert" title="g_list_insert ()"><code class="function">g_list_insert()</code></a> and
<a class="link" href="glib-Doubly-Linked-Lists.html#g-list-insert-sorted" title="g_list_insert_sorted ()"><code class="function">g_list_insert_sorted()</code></a> and so is rarely used on its own.</p>
<div class="refsect3">
<a name="g-list-alloc.returns"></a><h4>Returns</h4>
<p> a pointer to the newly-allocated <a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a> element</p>
</div>
</div>
<hr>
<div class="refsect2">
<a name="g-list-free-1"></a><h3>g_list_free_1 ()</h3>
<pre class="programlisting"><span class="returnvalue">void</span>
g_list_free_1 (<em class="parameter"><code><a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a> *list</code></em>);</pre>
<p>Frees one <a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a> element, but does not update links from the next and
previous elements in the list, so you should not call this function on an
element that is currently part of a list.</p>
<p>It is usually used after <a class="link" href="glib-Doubly-Linked-Lists.html#g-list-remove-link" title="g_list_remove_link ()"><code class="function">g_list_remove_link()</code></a>.</p>
<div class="refsect3">
<a name="g-list-free-1.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody><tr>
<td class="parameter_name"><p>list</p></td>
<td class="parameter_description"><p>a <a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a> element</p></td>
<td class="parameter_annotations"> </td>
</tr></tbody>
</table></div>
</div>
</div>
<hr>
<div class="refsect2">
<a name="g-list-length"></a><h3>g_list_length ()</h3>
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#guint" title="guint ()"><span class="returnvalue">guint</span></a>
g_list_length (<em class="parameter"><code><a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a> *list</code></em>);</pre>
<p>Gets the number of elements in a <a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a>.</p>
<p>This function iterates over the whole list to count its elements.
Use a <a class="link" href="glib-Double-ended-Queues.html#GQueue" title="struct GQueue"><span class="type">GQueue</span></a> instead of a GList if you regularly need the number
of items. To check whether the list is non-empty, it is faster to check
<em class="parameter"><code>list</code></em>
 against <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>.</p>
<div class="refsect3">
<a name="g-list-length.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody><tr>
<td class="parameter_name"><p>list</p></td>
<td class="parameter_description"><p>a <a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a>, this must point to the top of the list</p></td>
<td class="parameter_annotations"> </td>
</tr></tbody>
</table></div>
</div>
<div class="refsect3">
<a name="g-list-length.returns"></a><h4>Returns</h4>
<p> the number of elements in the <a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a></p>
</div>
</div>
<hr>
<div class="refsect2">
<a name="g-list-copy"></a><h3>g_list_copy ()</h3>
<pre class="programlisting"><a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="returnvalue">GList</span></a> *
g_list_copy (<em class="parameter"><code><a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a> *list</code></em>);</pre>
<p>Copies a <a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a>.</p>
<p>Note that this is a "shallow" copy. If the list elements 
consist of pointers to data, the pointers are copied but 
the actual data is not. See <a class="link" href="glib-Doubly-Linked-Lists.html#g-list-copy-deep" title="g_list_copy_deep ()"><code class="function">g_list_copy_deep()</code></a> if you need
to copy the data as well.</p>
<div class="refsect3">
<a name="g-list-copy.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody><tr>
<td class="parameter_name"><p>list</p></td>
<td class="parameter_description"><p>a <a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a>, this must point to the top of the list</p></td>
<td class="parameter_annotations"> </td>
</tr></tbody>
</table></div>
</div>
<div class="refsect3">
<a name="g-list-copy.returns"></a><h4>Returns</h4>
<p> the start of the new list that holds the same data as <em class="parameter"><code>list</code></em>
</p>
</div>
</div>
<hr>
<div class="refsect2">
<a name="g-list-copy-deep"></a><h3>g_list_copy_deep ()</h3>
<pre class="programlisting"><a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="returnvalue">GList</span></a> *
g_list_copy_deep (<em class="parameter"><code><a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a> *list</code></em>,
                  <em class="parameter"><code><a class="link" href="glib-N-ary-Trees.html#GCopyFunc" title="GCopyFunc ()"><span class="type">GCopyFunc</span></a> func</code></em>,
                  <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> user_data</code></em>);</pre>
<p>Makes a full (deep) copy of a <a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a>.</p>
<p>In contrast with <a class="link" href="glib-Doubly-Linked-Lists.html#g-list-copy" title="g_list_copy ()"><code class="function">g_list_copy()</code></a>, this function uses <em class="parameter"><code>func</code></em>
 to make
a copy of each list element, in addition to copying the list
container itself.</p>
<p><em class="parameter"><code>func</code></em>
, as a <a class="link" href="glib-N-ary-Trees.html#GCopyFunc" title="GCopyFunc ()"><span class="type">GCopyFunc</span></a>, takes two arguments, the data to be copied
and a <em class="parameter"><code>user_data</code></em>
 pointer. It's safe to pass <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a> as user_data,
if the copy function takes only one argument.</p>
<p>For instance, if <em class="parameter"><code>list</code></em>
 holds a list of GObjects, you can do:</p>
<div class="informalexample">
  <table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
    <tbody>
      <tr>
        <td class="listing_lines" align="right"><pre>1</pre></td>
        <td class="listing_code"><pre class="programlisting">another_list <span class="gtkdoc opt">=</span> <span class="function"><a href="glib-Doubly-Linked-Lists.html#g-list-copy-deep">g_list_copy_deep</a></span> <span class="gtkdoc opt">(</span>list<span class="gtkdoc opt">, (</span>GCopyFunc<span class="gtkdoc opt">)</span> g_object_ref<span class="gtkdoc opt">,</span> NULL<span class="gtkdoc opt">);</span></pre></td>
      </tr>
    </tbody>
  </table>
</div>

<p></p>
<p>And, to entirely free the new list, you could do:</p>
<div class="informalexample">
  <table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
    <tbody>
      <tr>
        <td class="listing_lines" align="right"><pre>1</pre></td>
        <td class="listing_code"><pre class="programlisting"><span class="function"><a href="glib-Doubly-Linked-Lists.html#g-list-free-full">g_list_free_full</a></span> <span class="gtkdoc opt">(</span>another_list<span class="gtkdoc opt">,</span> g_object_unref<span class="gtkdoc opt">);</span></pre></td>
      </tr>
    </tbody>
  </table>
</div>

<p></p>
<div class="refsect3">
<a name="g-list-copy-deep.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>list</p></td>
<td class="parameter_description"><p>a <a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a>, this must point to the top of the list</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>func</p></td>
<td class="parameter_description"><p>a copy function used to copy every element in the list</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>user_data</p></td>
<td class="parameter_description"><p>user data passed to the copy function <em class="parameter"><code>func</code></em>
, or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a></p></td>
<td class="parameter_annotations"> </td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect3">
<a name="g-list-copy-deep.returns"></a><h4>Returns</h4>
<p> the start of the new list that holds a full copy of <em class="parameter"><code>list</code></em>
,
use <a class="link" href="glib-Doubly-Linked-Lists.html#g-list-free-full" title="g_list_free_full ()"><code class="function">g_list_free_full()</code></a> to free it</p>
</div>
<p class="since">Since: <a class="link" href="api-index-2-34.html#api-index-2.34">2.34</a></p>
</div>
<hr>
<div class="refsect2">
<a name="g-list-reverse"></a><h3>g_list_reverse ()</h3>
<pre class="programlisting"><a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="returnvalue">GList</span></a> *
g_list_reverse (<em class="parameter"><code><a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a> *list</code></em>);</pre>
<p>Reverses a <a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a>.
It simply switches the next and prev pointers of each element.</p>
<div class="refsect3">
<a name="g-list-reverse.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody><tr>
<td class="parameter_name"><p>list</p></td>
<td class="parameter_description"><p>a <a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a>, this must point to the top of the list</p></td>
<td class="parameter_annotations"> </td>
</tr></tbody>
</table></div>
</div>
<div class="refsect3">
<a name="g-list-reverse.returns"></a><h4>Returns</h4>
<p> the start of the reversed <a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a></p>
</div>
</div>
<hr>
<div class="refsect2">
<a name="g-list-sort"></a><h3>g_list_sort ()</h3>
<pre class="programlisting"><a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="returnvalue">GList</span></a> *
g_list_sort (<em class="parameter"><code><a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a> *list</code></em>,
             <em class="parameter"><code><a class="link" href="glib-Doubly-Linked-Lists.html#GCompareFunc" title="GCompareFunc ()"><span class="type">GCompareFunc</span></a> compare_func</code></em>);</pre>
<p>Sorts a <a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a> using the given comparison function. The algorithm 
used is a stable sort.</p>
<div class="refsect3">
<a name="g-list-sort.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>list</p></td>
<td class="parameter_description"><p>a <a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a>, this must point to the top of the list</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>compare_func</p></td>
<td class="parameter_description"><p>the comparison function used to sort the <a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a>.
This function is passed the data from 2 elements of the <a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a>
and should return 0 if they are equal, a negative value if the
first element comes before the second, or a positive value if
the first element comes after the second.</p></td>
<td class="parameter_annotations"> </td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect3">
<a name="g-list-sort.returns"></a><h4>Returns</h4>
<p> the (possibly changed) start of the <a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a></p>
</div>
</div>
<hr>
<div class="refsect2">
<a name="GCompareFunc"></a><h3>GCompareFunc ()</h3>
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gint" title="gint ()"><span class="returnvalue">gint</span></a>
<span class="c_punctuation">(</span>*GCompareFunc<span class="c_punctuation">)</span> (<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gconstpointer" title="gconstpointer"><span class="type">gconstpointer</span></a> a</code></em>,
                 <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gconstpointer" title="gconstpointer"><span class="type">gconstpointer</span></a> b</code></em>);</pre>
<p>Specifies the type of a comparison function used to compare two
values.  The function should return a negative integer if the first
value comes before the second, 0 if they are equal, or a positive
integer if the first value comes after the second.</p>
<div class="refsect3">
<a name="GCompareFunc.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>a</p></td>
<td class="parameter_description"><p>a value</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>b</p></td>
<td class="parameter_description"><p>a value to compare with</p></td>
<td class="parameter_annotations"> </td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect3">
<a name="GCompareFunc.returns"></a><h4>Returns</h4>
<p> negative value if <em class="parameter"><code>a</code></em>
&lt; <em class="parameter"><code>b</code></em>
; zero if <em class="parameter"><code>a</code></em>
= <em class="parameter"><code>b</code></em>
; positive
value if <em class="parameter"><code>a</code></em>
&gt; <em class="parameter"><code>b</code></em>
</p>
</div>
</div>
<hr>
<div class="refsect2">
<a name="g-list-insert-sorted-with-data"></a><h3>g_list_insert_sorted_with_data ()</h3>
<pre class="programlisting"><a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="returnvalue">GList</span></a> *
g_list_insert_sorted_with_data (<em class="parameter"><code><a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a> *list</code></em>,
                                <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> data</code></em>,
                                <em class="parameter"><code><a class="link" href="glib-Doubly-Linked-Lists.html#GCompareDataFunc" title="GCompareDataFunc ()"><span class="type">GCompareDataFunc</span></a> func</code></em>,
                                <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> user_data</code></em>);</pre>
<p>Inserts a new element into the list, using the given comparison 
function to determine its position.</p>
<p>If you are adding many new elements to a list, and the number of
new elements is much larger than the length of the list, use
<a class="link" href="glib-Doubly-Linked-Lists.html#g-list-prepend" title="g_list_prepend ()"><code class="function">g_list_prepend()</code></a> to add the new items and sort the list afterwards
with <a class="link" href="glib-Doubly-Linked-Lists.html#g-list-sort" title="g_list_sort ()"><code class="function">g_list_sort()</code></a>.</p>
<div class="refsect3">
<a name="g-list-insert-sorted-with-data.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>list</p></td>
<td class="parameter_description"><p>a pointer to a <a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a>, this must point to the top of the
already sorted list</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>data</p></td>
<td class="parameter_description"><p>the data for the new element</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>func</p></td>
<td class="parameter_description"><p>the function to compare elements in the list. It should
return a number &gt; 0 if the first parameter  comes after the
second parameter in the sort order.</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>user_data</p></td>
<td class="parameter_description"><p>user data to pass to comparison function</p></td>
<td class="parameter_annotations"> </td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect3">
<a name="g-list-insert-sorted-with-data.returns"></a><h4>Returns</h4>
<p> the (possibly changed) start of the <a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a></p>
</div>
<p class="since">Since: <a class="link" href="api-index-2-10.html#api-index-2.10">2.10</a></p>
</div>
<hr>
<div class="refsect2">
<a name="g-list-sort-with-data"></a><h3>g_list_sort_with_data ()</h3>
<pre class="programlisting"><a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="returnvalue">GList</span></a> *
g_list_sort_with_data (<em class="parameter"><code><a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a> *list</code></em>,
                       <em class="parameter"><code><a class="link" href="glib-Doubly-Linked-Lists.html#GCompareDataFunc" title="GCompareDataFunc ()"><span class="type">GCompareDataFunc</span></a> compare_func</code></em>,
                       <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> user_data</code></em>);</pre>
<p>Like <a class="link" href="glib-Doubly-Linked-Lists.html#g-list-sort" title="g_list_sort ()"><code class="function">g_list_sort()</code></a>, but the comparison function accepts 
a user data argument.</p>
<div class="refsect3">
<a name="g-list-sort-with-data.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>list</p></td>
<td class="parameter_description"><p>a <a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a>, this must point to the top of the list</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>compare_func</p></td>
<td class="parameter_description"><p>comparison function</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>user_data</p></td>
<td class="parameter_description"><p>user data to pass to comparison function</p></td>
<td class="parameter_annotations"> </td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect3">
<a name="g-list-sort-with-data.returns"></a><h4>Returns</h4>
<p> the (possibly changed) start of the <a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a></p>
</div>
</div>
<hr>
<div class="refsect2">
<a name="GCompareDataFunc"></a><h3>GCompareDataFunc ()</h3>
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gint" title="gint ()"><span class="returnvalue">gint</span></a>
<span class="c_punctuation">(</span>*GCompareDataFunc<span class="c_punctuation">)</span> (<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gconstpointer" title="gconstpointer"><span class="type">gconstpointer</span></a> a</code></em>,
                     <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gconstpointer" title="gconstpointer"><span class="type">gconstpointer</span></a> b</code></em>,
                     <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> user_data</code></em>);</pre>
<p>Specifies the type of a comparison function used to compare two
values.  The function should return a negative integer if the first
value comes before the second, 0 if they are equal, or a positive
integer if the first value comes after the second.</p>
<div class="refsect3">
<a name="GCompareDataFunc.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>a</p></td>
<td class="parameter_description"><p>a value</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>b</p></td>
<td class="parameter_description"><p>a value to compare with</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>user_data</p></td>
<td class="parameter_description"><p>user data</p></td>
<td class="parameter_annotations"> </td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect3">
<a name="GCompareDataFunc.returns"></a><h4>Returns</h4>
<p> negative value if <em class="parameter"><code>a</code></em>
&lt; <em class="parameter"><code>b</code></em>
; zero if <em class="parameter"><code>a</code></em>
= <em class="parameter"><code>b</code></em>
; positive
value if <em class="parameter"><code>a</code></em>
&gt; <em class="parameter"><code>b</code></em>
</p>
</div>
</div>
<hr>
<div class="refsect2">
<a name="g-list-concat"></a><h3>g_list_concat ()</h3>
<pre class="programlisting"><a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="returnvalue">GList</span></a> *
g_list_concat (<em class="parameter"><code><a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a> *list1</code></em>,
               <em class="parameter"><code><a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a> *list2</code></em>);</pre>
<p>Adds the second <a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a> onto the end of the first <a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a>.
Note that the elements of the second <a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a> are not copied.
They are used directly.</p>
<p>This function is for example used to move an element in the list.
The following example moves an element to the top of the list:</p>
<div class="informalexample">
  <table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
    <tbody>
      <tr>
        <td class="listing_lines" align="right"><pre>1
2</pre></td>
        <td class="listing_code"><pre class="programlisting">list <span class="gtkdoc opt">=</span> <span class="function"><a href="glib-Doubly-Linked-Lists.html#g-list-remove-link">g_list_remove_link</a></span> <span class="gtkdoc opt">(</span>list<span class="gtkdoc opt">,</span> llink<span class="gtkdoc opt">);</span>
list <span class="gtkdoc opt">=</span> <span class="function"><a href="glib-Doubly-Linked-Lists.html#g-list-concat">g_list_concat</a></span> <span class="gtkdoc opt">(</span>llink<span class="gtkdoc opt">,</span> list<span class="gtkdoc opt">);</span></pre></td>
      </tr>
    </tbody>
  </table>
</div>

<p></p>
<div class="refsect3">
<a name="g-list-concat.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>list1</p></td>
<td class="parameter_description"><p>a <a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a>, this must point to the top of the list</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>list2</p></td>
<td class="parameter_description"><p>the <a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a> to add to the end of the first <a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a>,
this must point  to the top of the list</p></td>
<td class="parameter_annotations"> </td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect3">
<a name="g-list-concat.returns"></a><h4>Returns</h4>
<p> the start of the new <a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a>, which equals <em class="parameter"><code>list1</code></em>
if not <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a> </p>
</div>
</div>
<hr>
<div class="refsect2">
<a name="g-list-foreach"></a><h3>g_list_foreach ()</h3>
<pre class="programlisting"><span class="returnvalue">void</span>
g_list_foreach (<em class="parameter"><code><a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a> *list</code></em>,
                <em class="parameter"><code><a class="link" href="glib-Doubly-Linked-Lists.html#GFunc" title="GFunc ()"><span class="type">GFunc</span></a> func</code></em>,
                <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> user_data</code></em>);</pre>
<p>Calls a function for each element of a <a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a>.</p>
<div class="refsect3">
<a name="g-list-foreach.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>list</p></td>
<td class="parameter_description"><p>a <a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a>, this must point to the top of the list</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>func</p></td>
<td class="parameter_description"><p>the function to call with each element's data</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>user_data</p></td>
<td class="parameter_description"><p>user data to pass to the function</p></td>
<td class="parameter_annotations"> </td>
</tr>
</tbody>
</table></div>
</div>
</div>
<hr>
<div class="refsect2">
<a name="GFunc"></a><h3>GFunc ()</h3>
<pre class="programlisting"><span class="returnvalue">void</span>
<span class="c_punctuation">(</span>*GFunc<span class="c_punctuation">)</span> (<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> data</code></em>,
          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> user_data</code></em>);</pre>
<p>Specifies the type of functions passed to <a class="link" href="glib-Doubly-Linked-Lists.html#g-list-foreach" title="g_list_foreach ()"><code class="function">g_list_foreach()</code></a> and
<a class="link" href="glib-Singly-Linked-Lists.html#g-slist-foreach" title="g_slist_foreach ()"><code class="function">g_slist_foreach()</code></a>.</p>
<div class="refsect3">
<a name="GFunc.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>data</p></td>
<td class="parameter_description"><p>the element's data</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>user_data</p></td>
<td class="parameter_description"><p>user data passed to <a class="link" href="glib-Doubly-Linked-Lists.html#g-list-foreach" title="g_list_foreach ()"><code class="function">g_list_foreach()</code></a> or <a class="link" href="glib-Singly-Linked-Lists.html#g-slist-foreach" title="g_slist_foreach ()"><code class="function">g_slist_foreach()</code></a></p></td>
<td class="parameter_annotations"> </td>
</tr>
</tbody>
</table></div>
</div>
</div>
<hr>
<div class="refsect2">
<a name="g-list-first"></a><h3>g_list_first ()</h3>
<pre class="programlisting"><a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="returnvalue">GList</span></a> *
g_list_first (<em class="parameter"><code><a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a> *list</code></em>);</pre>
<p>Gets the first element in a <a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a>.</p>
<div class="refsect3">
<a name="g-list-first.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody><tr>
<td class="parameter_name"><p>list</p></td>
<td class="parameter_description"><p>any <a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a> element</p></td>
<td class="parameter_annotations"> </td>
</tr></tbody>
</table></div>
</div>
<div class="refsect3">
<a name="g-list-first.returns"></a><h4>Returns</h4>
<p> the first element in the <a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a>,
or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a> if the <a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a> has no elements</p>
</div>
</div>
<hr>
<div class="refsect2">
<a name="g-list-last"></a><h3>g_list_last ()</h3>
<pre class="programlisting"><a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="returnvalue">GList</span></a> *
g_list_last (<em class="parameter"><code><a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a> *list</code></em>);</pre>
<p>Gets the last element in a <a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a>.</p>
<div class="refsect3">
<a name="g-list-last.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody><tr>
<td class="parameter_name"><p>list</p></td>
<td class="parameter_description"><p>any <a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a> element</p></td>
<td class="parameter_annotations"> </td>
</tr></tbody>
</table></div>
</div>
<div class="refsect3">
<a name="g-list-last.returns"></a><h4>Returns</h4>
<p> the last element in the <a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a>,
or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a> if the <a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a> has no elements</p>
</div>
</div>
<hr>
<div class="refsect2">
<a name="g-list-previous"></a><h3>g_list_previous()</h3>
<pre class="programlisting">#define             g_list_previous(list)</pre>
<p>A convenience macro to get the previous element in a <a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a>.
Note that it is considered perfectly acceptable to access
<em class="parameter"><code>list-&gt;prev</code></em>
 directly.</p>
<div class="refsect3">
<a name="g-list-previous.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody><tr>
<td class="parameter_name"><p>list</p></td>
<td class="parameter_description"><p>an element in a <a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a></p></td>
<td class="parameter_annotations"> </td>
</tr></tbody>
</table></div>
</div>
<div class="refsect3">
<a name="g-list-previous.returns"></a><h4>Returns</h4>
<p> the previous element, or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a> if there are no previous
elements</p>
</div>
</div>
<hr>
<div class="refsect2">
<a name="g-list-next"></a><h3>g_list_next()</h3>
<pre class="programlisting">#define             g_list_next(list)</pre>
<p>A convenience macro to get the next element in a <a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a>.
Note that it is considered perfectly acceptable to access
<em class="parameter"><code>list-&gt;next</code></em>
 directly.</p>
<div class="refsect3">
<a name="g-list-next.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody><tr>
<td class="parameter_name"><p>list</p></td>
<td class="parameter_description"><p>an element in a <a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a></p></td>
<td class="parameter_annotations"> </td>
</tr></tbody>
</table></div>
</div>
<div class="refsect3">
<a name="g-list-next.returns"></a><h4>Returns</h4>
<p> the next element, or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a> if there are no more elements</p>
</div>
</div>
<hr>
<div class="refsect2">
<a name="g-list-nth"></a><h3>g_list_nth ()</h3>
<pre class="programlisting"><a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="returnvalue">GList</span></a> *
g_list_nth (<em class="parameter"><code><a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a> *list</code></em>,
            <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#guint" title="guint ()"><span class="type">guint</span></a> n</code></em>);</pre>
<p>Gets the element at the given position in a <a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a>.</p>
<p>This iterates over the list until it reaches the <em class="parameter"><code>n</code></em>
-th position. If you
intend to iterate over every element, it is better to use a for-loop as
described in the <a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a> introduction.</p>
<div class="refsect3">
<a name="g-list-nth.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>list</p></td>
<td class="parameter_description"><p>a <a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a>, this must point to the top of the list</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>n</p></td>
<td class="parameter_description"><p>the position of the element, counting from 0</p></td>
<td class="parameter_annotations"> </td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect3">
<a name="g-list-nth.returns"></a><h4>Returns</h4>
<p> the element, or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a> if the position is off
the end of the <a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a></p>
</div>
</div>
<hr>
<div class="refsect2">
<a name="g-list-nth-data"></a><h3>g_list_nth_data ()</h3>
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="returnvalue">gpointer</span></a>
g_list_nth_data (<em class="parameter"><code><a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a> *list</code></em>,
                 <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#guint" title="guint ()"><span class="type">guint</span></a> n</code></em>);</pre>
<p>Gets the data of the element at the given position.</p>
<p>This iterates over the list until it reaches the <em class="parameter"><code>n</code></em>
-th position. If you
intend to iterate over every element, it is better to use a for-loop as
described in the <a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a> introduction.</p>
<div class="refsect3">
<a name="g-list-nth-data.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>list</p></td>
<td class="parameter_description"><p>a <a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a>, this must point to the top of the list</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>n</p></td>
<td class="parameter_description"><p>the position of the element</p></td>
<td class="parameter_annotations"> </td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect3">
<a name="g-list-nth-data.returns"></a><h4>Returns</h4>
<p> the element's data, or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a> if the position
is off the end of the <a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a></p>
</div>
</div>
<hr>
<div class="refsect2">
<a name="g-list-nth-prev"></a><h3>g_list_nth_prev ()</h3>
<pre class="programlisting"><a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="returnvalue">GList</span></a> *
g_list_nth_prev (<em class="parameter"><code><a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a> *list</code></em>,
                 <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#guint" title="guint ()"><span class="type">guint</span></a> n</code></em>);</pre>
<p>Gets the element <em class="parameter"><code>n</code></em>
 places before <em class="parameter"><code>list</code></em>
.</p>
<div class="refsect3">
<a name="g-list-nth-prev.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>list</p></td>
<td class="parameter_description"><p>a <a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a></p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>n</p></td>
<td class="parameter_description"><p>the position of the element, counting from 0</p></td>
<td class="parameter_annotations"> </td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect3">
<a name="g-list-nth-prev.returns"></a><h4>Returns</h4>
<p> the element, or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a> if the position is
off the end of the <a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a></p>
</div>
</div>
<hr>
<div class="refsect2">
<a name="g-list-find"></a><h3>g_list_find ()</h3>
<pre class="programlisting"><a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="returnvalue">GList</span></a> *
g_list_find (<em class="parameter"><code><a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a> *list</code></em>,
             <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gconstpointer" title="gconstpointer"><span class="type">gconstpointer</span></a> data</code></em>);</pre>
<p>Finds the element in a <a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a> which contains the given data.</p>
<div class="refsect3">
<a name="g-list-find.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>list</p></td>
<td class="parameter_description"><p>a <a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a>, this must point to the top of the list</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>data</p></td>
<td class="parameter_description"><p>the element data to find</p></td>
<td class="parameter_annotations"> </td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect3">
<a name="g-list-find.returns"></a><h4>Returns</h4>
<p> the found <a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a> element, or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a> if it is not found</p>
</div>
</div>
<hr>
<div class="refsect2">
<a name="g-list-find-custom"></a><h3>g_list_find_custom ()</h3>
<pre class="programlisting"><a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="returnvalue">GList</span></a> *
g_list_find_custom (<em class="parameter"><code><a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a> *list</code></em>,
                    <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gconstpointer" title="gconstpointer"><span class="type">gconstpointer</span></a> data</code></em>,
                    <em class="parameter"><code><a class="link" href="glib-Doubly-Linked-Lists.html#GCompareFunc" title="GCompareFunc ()"><span class="type">GCompareFunc</span></a> func</code></em>);</pre>
<p>Finds an element in a <a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a>, using a supplied function to 
find the desired element. It iterates over the list, calling 
the given function which should return 0 when the desired 
element is found. The function takes two <a class="link" href="glib-Basic-Types.html#gconstpointer" title="gconstpointer"><span class="type">gconstpointer</span></a> arguments, 
the <a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a> element's data as the first argument and the 
given user data.</p>
<div class="refsect3">
<a name="g-list-find-custom.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>list</p></td>
<td class="parameter_description"><p>a <a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a>, this must point to the top of the list</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>data</p></td>
<td class="parameter_description"><p>user data passed to the function</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>func</p></td>
<td class="parameter_description"><p>the function to call for each element.
It should return 0 when the desired element is found</p></td>
<td class="parameter_annotations"> </td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect3">
<a name="g-list-find-custom.returns"></a><h4>Returns</h4>
<p> the found <a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a> element, or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a> if it is not found</p>
</div>
</div>
<hr>
<div class="refsect2">
<a name="g-list-position"></a><h3>g_list_position ()</h3>
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gint" title="gint ()"><span class="returnvalue">gint</span></a>
g_list_position (<em class="parameter"><code><a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a> *list</code></em>,
                 <em class="parameter"><code><a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a> *llink</code></em>);</pre>
<p>Gets the position of the given element 
in the <a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a> (starting from 0).</p>
<div class="refsect3">
<a name="g-list-position.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>list</p></td>
<td class="parameter_description"><p>a <a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a>, this must point to the top of the list</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>llink</p></td>
<td class="parameter_description"><p>an element in the <a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a></p></td>
<td class="parameter_annotations"> </td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect3">
<a name="g-list-position.returns"></a><h4>Returns</h4>
<p> the position of the element in the <a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a>,
or -1 if the element is not found</p>
</div>
</div>
<hr>
<div class="refsect2">
<a name="g-list-index"></a><h3>g_list_index ()</h3>
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gint" title="gint ()"><span class="returnvalue">gint</span></a>
g_list_index (<em class="parameter"><code><a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a> *list</code></em>,
              <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gconstpointer" title="gconstpointer"><span class="type">gconstpointer</span></a> data</code></em>);</pre>
<p>Gets the position of the element containing 
the given data (starting from 0).</p>
<div class="refsect3">
<a name="g-list-index.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>list</p></td>
<td class="parameter_description"><p>a <a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a>, this must point to the top of the list</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>data</p></td>
<td class="parameter_description"><p>the data to find</p></td>
<td class="parameter_annotations"> </td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect3">
<a name="g-list-index.returns"></a><h4>Returns</h4>
<p> the index of the element containing the data,
or -1 if the data is not found</p>
</div>
</div>
</div>
<div class="refsect1">
<a name="glib-Doubly-Linked-Lists.other_details"></a><h2>Types and Values</h2>
<div class="refsect2">
<a name="GList"></a><h3>struct GList</h3>
<pre class="programlisting">struct GList {
  gpointer data;
  GList *next;
  GList *prev;
};
</pre>
<p>The <a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a> struct is used for each element in a doubly-linked list.</p>
<div class="refsect3">
<a name="GList.members"></a><h4>Members</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="300px" class="struct_members_name">
<col class="struct_members_description">
<col width="200px" class="struct_members_annotations">
</colgroup>
<tbody>
<tr>
<td class="struct_member_name"><p><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> <em class="structfield"><code><a name="GList.data"></a>data</code></em>;</p></td>
<td class="struct_member_description"><p>holds the element's data, which can be a pointer to any kind
of data, or any integer value using the
<a class="link" href="glib-Type-Conversion-Macros.html" title="Type Conversion Macros">Type Conversion Macros</a></p></td>
<td class="struct_member_annotations"> </td>
</tr>
<tr>
<td class="struct_member_name"><p><a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a> *<em class="structfield"><code><a name="GList.next"></a>next</code></em>;</p></td>
<td class="struct_member_description"><p>contains the link to the next element in the list</p></td>
<td class="struct_member_annotations"> </td>
</tr>
<tr>
<td class="struct_member_name"><p><a class="link" href="glib-Doubly-Linked-Lists.html#GList" title="struct GList"><span class="type">GList</span></a> *<em class="structfield"><code><a name="GList.prev"></a>prev</code></em>;</p></td>
<td class="struct_member_description"><p>contains the link to the previous element in the list</p></td>
<td class="struct_member_annotations"> </td>
</tr>
</tbody>
</table></div>
</div>
</div>
<hr>
<div class="refsect2">
<a name="g-list-free1"></a><h3>g_list_free1</h3>
<pre class="programlisting">#define             g_list_free1</pre>
<p>Another name for <a class="link" href="glib-Doubly-Linked-Lists.html#g-list-free-1" title="g_list_free_1 ()"><code class="function">g_list_free_1()</code></a>.</p>
</div>
</div>
</div>
<div class="footer">
<hr>Generated by GTK-Doc V1.26.1</div>
</body>
</html>